﻿<html lang=en>
	<head>
		<meta charset=utf-8>
		<meta http-equiv=X-UA-Compatible content="IE=edge">
		<meta name=viewport content="width=device-width,initial-scale=1">		
		<title></title>		
		<link rel="stylesheet" href="style.css" />
	</head>
	<body>
		<h1>Plugin.Window API Reference</h1>

		<label>Introduction</label>
		<p>
			This plugin is specialized to get and set system window properties.
		</p>

		<label>Plugin object:</label>
		<p>
			<code>
				<i class="tab"></i>plugin = _G.plugins.Window <tag>-- get the plugin object</tag>
			</code>
		</p>

		<label class="subject">Plugin methods:</label>
		<ul>
			<li><a href="#FindWindow">plugin.FindWindow</a></li>
			<li><a href="#GetAllWindows">plugin.GetAllWindows</a></li>
			<li><a href="#IsWindow">plugin.IsWindow</a></li>
			<li><a href="#GetWindowText">plugin.GetWindowText</a></li>
			<li><a href="#GetClassName">plugin.GetClassName</a></li>
			<li><a href="#GetWindowRect">plugin.GetWindowRect</a></li>
			<li><a href="#GetClientRect">plugin.GetClientRect</a></li>
			<li><a href="#WindowToScreen">plugin.WindowToScreen</a></li>
			<li><a href="#ClientToScreen">plugin.ClientToScreen</a></li>
			<li><a href="#GetForegroundWindow">plugin.GetForegroundWindow</a></li>
			<li><a href="#SetForegroundWindow">plugin.SetForegroundWindow</a></li>
			<li><a href="#IsMinimized">plugin.IsMinimized</a></li>
			<li><a href="#IsMaximized">plugin.IsMaximized</a></li>
			<li><a href="#IsWindowVisible">plugin.IsWindowVisible</a></li>
			<li><a href="#ShowWindow">plugin.ShowWindow</a></li>
			<li><a href="#SendMessage">plugin.SendMessage</a></li>
			<li><a href="#SendMessage">plugin.PostMessage</a></li>
		</ul>
		<p></p>

		<a name="FindWindow"></a>
		<label>plugin.FindWindow</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.FindWindow(windowText [, className])</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>windowText:</dfn> title text of the window, null to ignore<br />
					<dfn>className:</dfn> class name of the window, null to ignore<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns IntPtr handle of the window if found, or null otherwise.
				</td>
			</tr>
			<tr>
				<td>Samples</td>
				<td>
					<code>local plugin = _G.plugins.Window</code>
					<code>local hwnd = plugin.FindWindow("Diablo II") <tag>-- hwnd is nil if "Diablo II" window does not exist</tag></code>
				</td>
			</tr>
		</table>

		<a name="GetAllWindows"></a>
		<label>plugin.GetAllWindows</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.GetAllWindows([visibleOnly])</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>visibleOnly:</dfn> if true, only visible windows will be returned.<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>Returns an array of IntPtr handles for all top-level windows</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>Retrieves all top-level windows.</td>
			</tr>
		</table>

		<a name="IsWindow"></a>
		<label>plugin.IsWindow</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.IsWindow(hwnd)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns true if hwnd is a handle to a valid window, false otherwise.
				</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>Examinates whether a window is still valid.</td>
			</tr>
		</table>

		<a name="GetWindowText"></a>
		<label>plugin.GetWindowText</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.GetWindowText(hwnd)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns window text if the window exists, nil otherwise.
				</td>
			</tr>
		</table>

		<a name="GetClassName"></a>
		<label>plugin.GetClassName</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.GetClassName(hwnd)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns class name if the window exists, nil otherwise.
				</td>
			</tr>
		</table>

		<a name="GetWindowRect"></a>
		<label>plugin.GetWindowRect</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.GetWindowRect(hwnd)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns left, top, width, height of the window if success, nil otherwise.
				</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>Retrieves boundary recangle of the window.</td>
			</tr>
		</table>

		<a name="GetClientRect"></a>
		<label>plugin.GetClientRect</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.GetClientRect(hwnd)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns left, top, width, height of the window client area if success, nil otherwise.
				</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>Retrieves boundary recangle of the window's client area.</td>
			</tr>
		</table>

		<a name="WindowToScreen"></a>
		<label>plugin.WindowToScreen</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.WindowToScreen(hwnd)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns x, y distance from the window to screen, both in left-top corners, if success, nil otherwise.
				</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>Retrieves distance from a window to screen, both in left-top corners.</td>
			</tr>
		</table>

		<a name="ClientToScreen"></a>
		<label>plugin.ClientToScreen</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.ClientToScreen(hwnd)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns x, y distance from the client area of a window to screen, both in left-top corners, if success, nil otherwise.
				</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>Retrieves distance from the client area of a window to screen, both in left-top corners.</td>
			</tr>
		</table>

		<a name="GetForegroundWindow"></a>
		<label>plugin.GetForegroundWindow</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.GetForegroundWindow()</code></td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns IntPtr handle to the foreground window.
				</td>
			</tr>
		</table>

		<a name="SetForegroundWindow"></a>
		<label>plugin.SetForegroundWindow</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.SetForegroundWindow(hwnd)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns true if success, false otherwise.
				</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>Brings a window to foreground.</td>
			</tr>
		</table>

		<a name="IsMinimized"></a>
		<label>plugin.IsMinimized</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.IsMinimized(hwnd)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns true if the window is valid and minimized, false otherwise.
				</td>
			</tr>
		</table>

		<a name="IsMaximized"></a>
		<label>plugin.IsMaximized</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.IsMaximized(hwnd)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns true if the window is valid and maximized, false otherwise.
				</td>
			</tr>
		</table>

		<a name="IsWindowVisible"></a>
		<label>plugin.IsWindowVisible</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.IsWindowVisible(hwnd)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns true if the window is valid and visible, false otherwise.
				</td>
			</tr>
		</table>

		<a name="ShowWindow"></a>
		<label>plugin.ShowWindow</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.ShowWindow(hwnd, command)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
					<dfn>command:</dfn> diaplaying type, the SW_xxx int value, can be one of the following:<br />
					<ul>
						<li><b>SW_SHOW</b> - Show the window if it's hidden.</li>
						<li><b>SW_HIDE</b> - Hide the window if it's shown.</li>
						<li><b>SW_RESTORE</b> - Restore the window if it's minimized.</li>
						<li><b>SW_NORMAL</b> - Show the window and remove minimized/maximized states.</li>
						<li><b>SW_MINIMIZE</b> - Minimize the window.</li>
						<li><b>SW_MAXIMIZE</b> - Maximize the window.</li>
					</ul>
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns true if the window is valid and success, false otherwise.
				</td>
			</tr>
			<tr>
				<td>Samples</td>
				<td>
					Changes the diaplaying type of a window.
					<code>local plugin = plugins.Window</code>
					<code>local hwnd = plugin.FindWindow("Diablo II")</code>
					<code>plugin.ShowWindow(hwnd, SW_MINIMIZE) <tag>-- minimize</tag></code>
				</td>
			</tr>
		</table>

		<a name="SendMessage"></a>
		<label>
			plugin.SendMessage<br />
			plugin.PostMessage
		</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td>
					<code>plugin.SendMessage(hwnd, msg, wparam, lparam)</code>
					<code>plugin.PostMessage(hwnd, msg, wparam, lparam)</code>
				</td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>hwnd:</dfn> IntPtr handle to a window<br />
					<dfn>msg:</dfn> int value of the message<br />
					<dfn>wparam, lparam:</dfn> message parameters<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns the native Win32API return value.
				</td>
			</tr>

			<tr>
				<td>Remarks</td>
				<td>
					Call these two methods only if you know exactly what you are doing.
				</td>
			</tr>
		</table>
	</body>
</html>